/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Connection.DataAccess;
import Model.ChiTietHoaDon;

/**
 *
 * @author My PC
 */
public class ChiTietHoaDonController {
     public static boolean ThemCTHD(ChiTietHoaDon cthd)
    {
        try 
        {
           String sql = "INSERT INTO tblChiTietHoaDon(MA_HOADON,MA_SANPHAM,"
                    + "SOLUONG)"
                   + "values (N'"+cthd.getMaHoadon()+"',N'"+cthd.getMaSanpham()+"',"
                   + " "+cthd.getSoluong()+")";    
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
     public static boolean XoaCTHD(ChiTietHoaDon cthd)
    {
        try 
        {
            
           String sql = "delete from tblChiTietHoaDon where MA_HOADON =N'"+cthd.getMaHoadon()+""
                   + "and MA_SANPHAM = N'"+cthd.getMaSanpham()+"'";
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
     
     public static boolean SuaCTHD(ChiTietHoaDon cthd)
    {
        try 
        {       
           String sql = "update from tblChiTietHoaDon where MA_HOADON =N'"+cthd.getMaHoadon()+""
                   + "and MA_SANPHAM = N'"+cthd.getMaSanpham()+"'";
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
